Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 15649Or
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 15649" |
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR unifies Aspire Type System (ATS) environment-variable exports across polyglot app hosts by consolidating multiple specialized WithEnvironment* capability exports into a single withEnvironment(name, value) capability that accepts a broader set of value types.
Changes:
- Introduces an internal
withEnvironmentdispatcher export that accepts a union of supported environment value types (string, expressions, endpoint refs, parameters, connection strings, value providers). - Removes specialized ATS exports (and generated polyglot APIs) like
withEnvironmentExpression,withEnvironmentEndpoint,withEnvironmentParameter, etc., updating TypeScript/Python codegen snapshots and ATS baselines accordingly. - Adds support types/interfaces for dispatching custom environment behavior and exports
IValueProvider/IManifestExpressionProviderinto ATS.
Reviewed changes
Copilot reviewed 18 out of 18 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests/Snapshots/TwoPassScanningGeneratedAspire.verified.ts | Snapshot updates reflecting unified TS withEnvironment union-typed API and removal of specialized methods. |
| tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests/Snapshots/HostingContainerResourceCapabilities.verified.txt | Removes specialized environment capability entries from TS capability baseline snapshot. |
| tests/Aspire.Hosting.CodeGeneration.Python.Tests/Snapshots/TwoPassScanningGeneratedAspire.verified.py | Snapshot updates reflecting unified Python with_env union typing and removal of specialized methods/options. |
| src/Aspire.Hosting/api/Aspire.Hosting.Capabilities.txt | ATS baseline updated: withEnvironment now takes a union of supported types; specialized exports removed. |
| src/Aspire.Hosting/ResourceBuilderExtensions.cs | Adds internal dispatcher export, value-provider wiring, and reflection-based custom dispatch mechanism. |
| src/Aspire.Hosting/ApplicationModel/IValueWithCustomWithEnvironment.cs | Introduces a new experimental interface for value-specific WithEnvironment dispatch behavior. |
| src/Aspire.Hosting/ApplicationModel/IValueProvider.cs | Exports IValueProvider into ATS. |
| src/Aspire.Hosting/ApplicationModel/IManifestExpressionProvider.cs | Exports IManifestExpressionProvider into ATS. |
| src/Aspire.Hosting.CodeGeneration.TypeScript/AtsTypeScriptCodeGenerator.cs | Updates TS generator to emit proper TS unions for ATS union parameters. |
| src/Aspire.Hosting.Azure/AzureBicepResourceExtensions.cs | Stops exporting Azure-specific withEnvironmentFrom* ATS methods; routes through unified environment API. |
| src/Aspire.Hosting.Azure/AzureBicepResource.cs | Makes BicepOutputReference provide custom WithEnvironment dispatch. |
| src/Aspire.Hosting.Azure.KeyVault/AzureKeyVaultSecretResource.cs | Adds custom WithEnvironment dispatch for Key Vault secret resource values. |
| src/Aspire.Hosting.Azure.KeyVault/AzureKeyVaultSecretReference.cs | Adds custom WithEnvironment dispatch for Key Vault secret references. |
| src/Aspire.Hosting.SqlServer/api/Aspire.Hosting.SqlServer.ats.txt | Refreshes checked-in ATS baseline for SqlServer package to match new shared capability set. |
| playground/polyglot/TypeScript/Aspire.Hosting/ValidationAppHost/apphost.ts | Updates playground usage to call unified withEnvironment for endpoint/parameter/connection-string values. |
| playground/polyglot/TypeScript/Aspire.Hosting.Azure/ValidationAppHost/apphost.ts | Updates playground usage to call unified withEnvironment for Bicep output & Key Vault secret values. |
| playground/polyglot/Python/Aspire.Hosting/ValidationAppHost/apphost.py | Updates playground usage to call unified with_environment for endpoint/parameter/connection-string values. |
| playground/polyglot/Python/Aspire.Hosting.Azure/ValidationAppHost/apphost.py | Updates playground usage to call unified with_environment for Bicep output & Key Vault secret values. |
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Keep the new IExpressionValue-based C# abstraction while collapsing ATS back to a single preview-only withEnvironment export. Update generated ATS artifacts and polyglot codegen snapshots to match the unified surface. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Keep the unified withEnvironment export while restoring legacy ATS alias methods as obsolete internal compatibility shims for existing polyglot apps. Regenerate capability dumps and refresh codegen snapshots to match the non-breaking export surface. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
| /// <param name="name">The name of the environment variable.</param> | ||
| /// <param name="value">The reference expression value.</param> | ||
| /// <returns>The <see cref="IResourceBuilder{T}"/>.</returns> | ||
| [Obsolete("ATS compatibility shim. Use withEnvironment instead. Remove after existing polyglot app hosts migrate.")] |
There was a problem hiding this comment.
This is only on an internal method for use to remember to remove this ATS method at some point. We can replace it by a dedicated [AspireExportObsolete] once we have it
|
🎬 CLI E2E Test Recordings — 52 recordings uploaded (commit View recordings
📹 Recordings uploaded automatically from CI run #23757986005 |
Description
Unifies ATS
WithEnvironmentexports so polyglot apphosts can use a singlewithEnvironment(name, value)API, following the same abstraction pattern used forwithReference.On the C# side, this adds the new public
IExpressionValueabstraction plus additiveWithEnvironment(..., IExpressionValue)support, giving environment values a common base type for cases that need both runtime values and manifest expressions without changing existing constructors or removing existing overloads.To avoid breaking existing polyglot apps, this PR also keeps the previous ATS
withEnvironment*aliases as obsolete internal compatibility shims (withEnvironmentExpression,withEnvironmentEndpoint,withEnvironmentParameter,withEnvironmentConnectionString,withEnvironmentFromOutput, andwithEnvironmentFromKeyVaultSecret). Comments in the shim implementations call out that they should be removed once callers have migrated to the unifiedwithEnvironment(...)export.The generated ATS artifacts plus TypeScript, Java, Python, Go, and Rust snapshots are refreshed to match that final non-breaking export surface.
Documentation follow-up: microsoft/aspire.dev#640
Fixes #3773
Checklist
<remarks />and<code />elements on your triple slash comments?aspire.devissue: